﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_CharColor : Command
    {
        public string name
        {
            get
            {
                return Value1;
            }
            set
            {
                Value1 = value;
            }
        }
        public Color color
        {
            get
            {
                return new Color { r = byte.Parse(Value2.Substring(0, 2), System.Globalization.NumberStyles.HexNumber), g = byte.Parse(Value2.Substring(2, 2), System.Globalization.NumberStyles.HexNumber), b = byte.Parse(Value2.Substring(4, 2), System.Globalization.NumberStyles.HexNumber) };
            }
            set
            {
                Value2 = value.r.ToString("X") + value.g.ToString("X") + value.b.ToString("X");
            }
        }
        public float duration
        {
            get
            {
                return float.TryParse(Value3, out float result) ? result : 0.5f;
            }
            set
            {
                Value3 = value.ToString();
            }
        }
        public Command_CharColor()
        {
            CommandType = COMMANDTYPE.CharColor;
            name = "请输入角色名";
            color = new Color { r = 255, g = 255, b = 255 };
            duration = 0.5f;
            Wait = true;
        }
        public Command_CharColor(string Name, Color Color, float Duration)
        {
            CommandType = COMMANDTYPE.CharColor;
            name = Name;
            color = Color;
            duration = Duration;
            Wait = true;
        }
        public override string ToString()
        {
            return CommandType.ToString() + ":\n" + "改变角色颜色：" + name + "为" + "r,g,b:" + color.r.ToString() + "," + color.g.ToString() + "," + color.b.ToString();
        }
    }
}
